<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/static/kindeditor/themes/default/default.css" />
		<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
		<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
		<script src="/bck/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" href="/static/webuploader/webuploader.css">
		<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
		<style type="text/css">
			#tj {
				position: fixed;
				top: 0px;
				left: 0px;
				width: 1920px;
				height: 910px;
				background: rgba(0, 0, 0, 0.3);
				color: #666;
			}
			
			#tj_1 {
				position: fixed;
				width: 732px;
				height: 882px;
				top: 23.5px;
				left: 750px;
				background: white;
			}
			
			#tj_1_1 {
				/*width: 100%;*/
				height: 50px;
				line-height: 50px;
				border: 0;
				background-color: #20222A;
				color: #fff;
				padding: 0 0px 0 20px;
			}
			
			#tj_1_2 {
				width: 420px;
				height: 962px;
				padding-left: 75px;
				padding-top: 24px;
			}
			
			#tjbtn {
				width: 64px;
				height: 38px;
				line-height: 38px;
				padding: 0 18px;
				background-color: #009688;
				color: #fff;
				white-space: nowrap;
				text-align: center;
				font-size: 14px;
				border: none;
				border-radius: 2px;
				cursor: pointer;
				margin-left: 130px;
			}
			
			.icon_false {
				display: inline-block;
				width: 14px;
				height: 2px;
				background: #fff;
				line-height: 0;
				font-size: 0;
				vertical-align: middle;
				-webkit-transform: rotate(45deg);
			}
			
			.icon_false:after {
				content: '/';
				display: block;
				width: 14px;
				height: 2px;
				background: #fff;
				-webkit-transform: rotate(-90deg);
			}
		</style>
	</head>
	<body>
		<!--添加-->
				<div id="tj_1_1">
					商品基本信息
				</div>
				<div id="tj_1_2">
					<div class="div1_1" style="margin-left: -14px;height: 38px;margin-bottom: 15px;">
						商品名称：<input id="name" type="text" class="input1" value="" placeholder="" style="margin-left: 17px;" />
					</div>
					<div class="div1_1" style="margin-left: 1px;height: 38px;margin-bottom: 15px;">
						价格：<input id="price" type="text" class="input1" value="" placeholder="" style="margin-left: 32px;" />
					</div>
					<div class="div1_1" style="height: 38px;margin-bottom: 15px;">所属品牌：
						<input id="brand" type="text" class="input1" value="" placeholder="" style="margin-left: -6px;" />
					</div>
					<div class="div1_1" style="height: 38px;margin-bottom: 15px;">所属分类：
						<input id="classify" type="text" class="input1" value="" placeholder="" style="margin-left: -6px;" />
					</div>
					<div class="div1_1" style="height: 38px;margin-bottom: 15px;">库存：
						<input id="inventory" type="text" class="input1" value="" placeholder="" style="margin-left: 26px;" />
					</div>
					<div class="div1_1" style="height: 241px;margin-bottom: 15px;">图片：
						<div id="uploader" class="wu-example" style="width: 500px;height: 118px;border: 2px dashed #000088;margin: auto">
							<!--用来存放文件信息-->
							<div id="thelist" class="uploader-list"></div>
							<div class="btns">
								<div id="picker">选择文件</div>
							</div>
						</div>
						<div id="img" style="margin-bottom: 10px;"></div>
					</div>
					<div class="div1_1" style="height: 38px;margin-bottom: 15px;">详情：
						<form action="" id="form" method="post">
							<textarea id="editor_id" name="content" style="width:700px;height:300px;">
									&lt;strong&gt;内容&lt;/strong&gt;
							</textarea>
						</form>
					</div>
				</div>
				<div id="tj_1_3">
					<button id="tjbtn">确认</button>
				</div>
		
		<script type="text/javascript" charset="utf-8">
			var editor ;
			var tp;
			var arr = [
				'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
				'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
				'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				'anchor', 'link', 'unlink', '|', 'about'
			];
			KindEditor.ready(function(K) {
				editor = K.create('#editor_id', {
					width: '100px', //设置编辑器的宽
					height: '400px',
					//items:['undo', 'redo']	只出现两个undo	后退redo	前进按钮
					items: arr, //设置工具栏的按钮
					uploadJson: '/ajax.php?ajax=upload', //文件上传程序
					fileManagerJson: '/ajax.php?ajax=file_manager', //浏览服务器图片空间
					allowFileManager: true, //启用图片空间按钮
				});
			});
			var uploader = WebUploader.create({
			            swf: '/static/webuploader/Uploader.swf',
			            server: '/webuploader.php',
			            pick: '#picker',//指名那个内容是上传按钮
			            resize: false,
			
			            // 选完文件后，是否自动上传。
			            auto:true,
			
			            //指定接受哪些类型的文件。
			            /*accept :{
			                    title: 'Images',
			                        extensions: 'gif,jpg,jpeg,bmp,png',
			                    mimeTypes: 'image/!*'
			                },*/
			            //指定Drag And Drop拖拽的容器，如果不指定，则不启动。(参数id)
			            dnd:'#uploader',
			
			            //是否禁掉整个页面的拖拽功能，如果不禁用，图片拖进来的时候会默认被浏览器打开。
			            disableGlobalDnd:true,
			
			            //是否要分片处理大文件上传。
			            //chunked:true,
			        });
					uploader.on( 'uploadSuccess', function( file,msg ) {
						console.log('----上传成功-----');
						console.log('/tmp/'+file.name);
						tp = 'tmp/'+file.name;
						//console.log(msg._raw);
						//console.log(msg);
						/* $.ajax({
							url:"/webuploader.php",
							type:'post',
							data:{
								act:1,
								name:file.name
							},
							success:function (msg) {
								console.log(msg);
							}
						}) */
					});
					uploader.on( 'fileQueued', function( file ) {
			
						//第一个为error，如果生成缩略图有错误，此error将为真。
						//第二个为ret, 缩略图的Data URL值。
						uploader.makeThumb( file, function( error, ret ) {
							if ( error ) {
								console.log('不是图片');
							} else {
								$("#img").append('<img src="'+ret+'"/>');
							}
						});
					});
					
			
			
			$("#tjbtn").click(function() {
				$("#tj").css("display", "none");
				$.ajax({
					type:'post',
					url:'/shangpinadd.php',
					data:{
						name:$('#name').val(),
						price:$('#price').val(),
						lb:tp,
						classify:$('#classify').val(),
						brand:$('#brand').val(),
						inventory:$('#inventory').val(),
						particulars:editor.html(),
					},
					dataType:'json',
					success:function(mgs){
						console.log(mgs);
						window.location.href="/shangpin - 副本.html";
					}
				});	
			});
		</script>
	</body>
</html>
